package utils;

import java.util.*;


public class XMLHelper{


    public static String XMLOpenTag(String element){
	return XMLOpenTag(element,(HashMap)null);
    }

    public static String XMLOpenTag(String element,
			 HashMap<String,Object> attributes){
	String tag = "\n<" + element;

	if(attributes != null){
	    tag = tag + " ";
	    //	    System.out.println(attributes);
	    for(String key : attributes.keySet()){
		String att = key + "=\"" + attributes.get(key).toString() + "\" ";
		tag = tag + att;
	    }
	}

	tag = tag + ">";
	return tag;	
    }

    public static String XMLCloseTag(String element){
	return "\n</" + element + ">";
    }

    public static String XMLCompleteTag(String element){
	return XMLCompleteTag(element,(HashMap)null);
    }
    public static String XMLCompleteTag(String element, HashMap<String,Object> attributes){
	String tag = "\n<" + element;
	
	if(attributes != null){
	    tag = tag + " ";
	    for(String key : attributes.keySet()){
		String att = key + "=\"" + attributes.get(key) + "\" ";
		tag = tag + att;
	    }
	}

	tag = tag + "/>";
	return tag;	
    }
}